//
//  ShowArrayCollectionViewCellTwo.m
//  GiftSay
//
//  Created by dllo on 16/1/12.
//  Copyright © 2016年 liyinkai. All rights reserved.
//

#import "ShowArrayCollectionViewCellTwo.h"

@interface ShowArrayCollectionViewCellTwo ()

@end

@implementation ShowArrayCollectionViewCellTwo

-(instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        self.xa = [UIButton buttonWithType:UIButtonTypeSystem];
        
        [self.xa setImage:[[UIImage imageNamed:@"x"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] forState:UIControlStateNormal];
        [self.xa addTarget:self action:@selector(dele:) forControlEvents:UIControlEventTouchDown];
        [self addSubview:self.xa];
    }
    return self;
}

-(void)applyLayoutAttributes:(UICollectionViewLayoutAttributes *)layoutAttributes {
    [super applyLayoutAttributes:layoutAttributes];
    self.xa.frame = CGRectMake((self.nameLabel.frame.origin.x + self.nameLabel.width) - (self.width / 6 / 2), self.nameLabel.frame.origin.y - (self.width / 6 / 2), self.width / 6, self.width / 6);

}


-(void)dele:(UIButton *)sender {
    [self.delegate dele:self.name];
}

-(void)setIfcell:(BOOL)ifcell {
    _ifcell = ifcell;
    if (ifcell == YES) {
        self.xa.hidden = YES;
        self.nameLabel.layer.borderWidth = 0;
        self.nameLabel.textColor = [UIColor grayColor];
    }
    else{
        self.xa.hidden = NO;
        self.nameLabel.layer.borderWidth = 1;
        self.nameLabel.textColor = [UIColor blackColor];
    }
}
@end
